#version 450

layout(binding = 0) uniform sampler2D tex;

in Varyings
{
    vec2 uv;
} i;

out vec4 fragColor;

const float r = 1.0 / 300.0;

void main()
{
    vec2 offsets[9] = {
        vec2(-r, r), vec2(0.0, r), vec2(r, r),
        vec2(-r, 0.0), vec2(0.0, 0.0), vec2(r, 0.0),
        vec2(-r, -r), vec2(0.0, -r), vec2(r, -r)
    };

    float kernel[9] = {
        1.0, 1.0, 1.0,
        1.0, -8.0, 1.0,
        1.0, 1.0, 1.0
    };

    vec3 color = vec3(0.0);
    for(int k = 0; k < 9; ++k)
    {
        color += texture(tex, i.uv + offsets[k]).rgb * kernel[k];
    }

    fragColor = vec4(color, 1.0);
}
